package com.aaa.dem1101;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/11/1  13:20
 */
public class Priority {
    public static void main(String[] args) {
        PriorityDemo t1=new PriorityDemo("线程A");
        PriorityDemo t2=new PriorityDemo("线程B");
        PriorityDemo t3=new PriorityDemo("线程C");
        //优先级值越大 获取cpu的概率越高  执行完越早
        t1.setPriority(1);
        t2.setPriority(5);
        t3.setPriority(10);
        t1.start();
        t2.start();
        t3.start();
    }
}
class PriorityDemo extends Thread{
    PriorityDemo(String name){
        super(name);
    }
    @Override
    public void run() {
        for (int i = 0; i <20 ; i++) {
            System.out.println(Thread.currentThread().getName()+"~~~~~~~~~"+i);
        }
    }
}
